<template>
  <div class="wrap">
    <div class="title">
      <div>我的優惠券</div>
      <div></div>
      <div>優惠券信息</div>
    </div>
   <div class="content">
      <div class="choose">
        <div :class="showType == 0?'select':'unselect'" @click="changeorder(0)">我的優惠券</div>
        <div :class="showType == 1?'select':'unselect'" @click="changeorder(1)">使用過的優惠券</div>
        <div :class="showType == 2?'select':'unselect'" @click="changeorder(2)">已過期的優惠券</div>
      </div>
    </div>
    <div v-if="showType == 0">
      <div class="use">
        <div class="usetu" v-for="(item,index) in coulist" :key="index">
          <div>{{item.name}} </div>
          <div>{{item.startTime}}至{{item.endTime}}</div>
          <!-- <div>卷編號:8208820880</div> -->
          <div v-if="item.goodsType == 0">品類限制:全品類</div>
          <div v-if="item.goodsType == 1">品類限制:類目限制</div>
          <div v-if="item.goodsType == 2">品類限制:商品限制</div>
        </div>
      </div>
    </div>
    <div v-if="showType == 1">
      <div class="use">
        <div class="usetued" v-for="(item,index) in coulist" :key="index">
          <div>{{item.name}} </div>
          <div>{{item.startTime}}至{{item.endTime}}</div>
          <!-- <div>卷編號:8208820880</div> -->
          <div v-if="item.goodsType == 0">品類限制:全品類</div>
          <div v-if="item.goodsType == 1">品類限制:類目限制</div>
          <div v-if="item.goodsType == 2">品類限制:商品限制</div>
        </div>
      </div>
    </div>
    <div v-if="showType == 2">
      <div class="use">
        <div class="unusetu" v-for="(item,index) in coulist" :key="index">
          <div>{{item.name}} </div>
          <div>{{item.startTime}}至{{item.endTime}}</div>
          <!-- <div>卷編號:8208820880</div> -->
          <div v-if="item.goodsType == 0">品類限制:全品類</div>
          <div v-if="item.goodsType == 1">品類限制:類目限制</div>
          <div v-if="item.goodsType == 2">品類限制:商品限制</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import {mylist} from '@/api/car'
// import {validatePhoneTwo,validateEMail,validatePassword,validateReferral,validateXing,validateMonth,validateDay} from '@/utils/validate';
// import {list} from '@/api/order';
import { getToken } from '@/utils/auth' // 驗權
export default {
  data(){
    return{
      showType:0,
      coulist:[]
    }
  },
  mounted(){
    this.getlist(0)
  },
  methods: {
    getlist(e){
      this.coulist = []
        mylist({userId:getToken(),status:e}).then(response => {
          console.log(response.data.list)
          if(response.errno == 0){
            if(response.data.list.length != 0){
              response.data.list.forEach(Element => {
                Element.endTime = Element.endTime.split(' ')[0]
                Element.startTime = Element.startTime.split(' ')[0]
              })
              this.coulist = response.data.list
            }else{
              this.coulist = []
            }
          }else{
            this.coulist = []
          }
          
        }) 
    },
    goorderfinish(){
      this.$router.push({path:'/orderfinish'})
    },
    changeorder(e){
      this.showType = e
      this.getlist(e)
    }
  }
}
</script>
<style scoped>
  .wrap{
    width: 100%;
    /* height: 1358px; */
    background: #F5F5F5;
    box-sizing: border-box;
  }
  .title{
    width: 100%;
    box-sizing: border-box;
    padding: 10px 20px 20px 20px;
    border-bottom: 1px solid #D8D8D8;
    background: #fff;
    display: flex;
    align-items: center;
    padding-bottom: 20px;
  }
  .title>div:nth-child(1){
    font-size: 19px;
    font-weight: bold;
    color: #333333;
    border-bottom: 3px solid #333333;
  }
  .title>div:nth-child(2){
    width: 8px;
    height: 2px;
    background: #333333;
    margin: 0px 10px;
  }
  .title>div:nth-child(3){
    font-size: 19px;
    font-weight: bold;
    color: #333333;
    border-bottom: 3px solid #333333;
  }
  .content{
    width: 100%;
    margin: 0 auto;
    height: 90px;
  }
  .choose{
    display: flex;
    height: 70px;
    align-items: center;
    text-align: center;
    padding:10px 0;
    background: #fff;
  }
  .select{
    width: 144px;
    height: 58px;
    display: flex;
    margin:0 20px;
    justify-content: center;
    align-items: center;
    background: #E2D4C2; 
    font-size: 18px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #FFFFFF;
    cursor:pointer;
  }
  .unselect{
    width: 144px;
    height: 58px;
    margin: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    cursor:pointer;
  }
  .purchese{
    margin: 0 auto;
    width: 96%;
    border: 1px solid #E5E5E5;
    margin-bottom:22px;
  }
  .purchesetop{
    display: flex;
    align-items: center;
    margin: 0 auto;
    width: 100%;
    height: 37px;
    background: #F5F5F5; 
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
  }
 .purchesetop div{
    display: flex;
    align-items: center;
    margin: 0 auto;
    width: 96%;
    height: 37px;
    background: #F5F5F5; 
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
  }
 .purchesebottom{
    margin: 0 auto;
    width: 100%;
    display: flex;
    border-bottom: 1px solid #E5E5E5;
  }
  .purimg{
    display: flex;
    padding: 0 17px;
    height: 113px;
    align-items: center;
  }
  .purimg img{
    width: 80px;
    height: 80px;
  }
  .purnumber{
    margin: 16px 0;
    width: 35%;
    height: 80px;
    align-items: center;
    border-right:1px solid #E5E5E5;
  }
  .purnumber>div:nth-child(1){
    height: 60px;
    line-height: 60px;
    align-items: center;
  }
  .purnumber>div:nth-child(2){
    align-items: center;
  }
  .purpay{
    margin: 16px 0;
    width: 15%;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right:1px solid #E5E5E5;
  }
  .purlinepay{
    margin: 16px 0;
    width: 25%;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    height: 80px;
    text-align: center;
    justify-content: center;
    border-right:1px solid #E5E5E5;
  }
  .purlinepay div{    
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    justify-content: center;
    color: #333333;
  }
  .purlinepays{
    width: 17%;
    margin: 16px 0;
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #333333;
    height: 80px;
    text-align: center;
    justify-content: center;
  }
  .purlinepays div{    
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    justify-content: center;
    color: #333333;
  }
  .time{
    display: flex;
    align-items: center;
    width: 100%;
  }
 .time div{    
    font-size: 12px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #E4393C;
  }
  .time img{    
    padding:0 6px;
    width: 18px;
    height: 18px;
  }
  .use{
    padding:32px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    word-wrap:break-word
  }
  .usetu{
    width: 300px;
    height: 286px;
    margin-bottom:48px;
    background-size: cover;
    background-image: url("../../../assets/use.png");
  }
  .usetu>div:nth-child(1){
    padding-top:66px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #343434;
  }
  .usetu>div:nth-child(2){
    padding-top:10px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .usetu>div:nth-child(3){
    padding-top:85px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .usetu>div:nth-child(4){
    padding-top:0px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .usetued{
    width: 300px;
    height: 286px;
    margin-bottom:48px;
    background-size: cover;
    background-image: url("../../../assets/used.png");
  }
  .usetued>div:nth-child(1){
    padding-top:66px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #343434;
  }
  .usetued>div:nth-child(2){
    padding-top:10px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .usetued>div:nth-child(3){
    padding-top:85px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .usetued>div:nth-child(4){
    padding-top:10px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .unusetu{
    width: 300px;
    height: 286px;
    margin-bottom:48px;
    background-size: cover;
    background-image: url("../../../assets/unuse.png");
  }
  .unusetu>div:nth-child(1){
    padding-top:66px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #343434;
  }
  .unusetu>div:nth-child(2){
    padding-top:10px;
    text-align: center;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .unusetu>div:nth-child(3){
    padding-top:85px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
  .unusetu>div:nth-child(4){
    padding-top:10px;
    padding-left:14px;
    font-size: 20px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #343434;
  }
</style>